
const app = {
    state: {
        // 中英文
        language: localStorage.getItem('language') || 'en_US',
        //token
        token: localStorage.getItem('token') || '',
        //用户信息
        userInfo: localStorage.getItem('userInfo') && JSON.parse(localStorage.getItem('userInfo')) || {},
    },
    mutations: {
        // 中英文
        SET_LANGUAGE: (state, language) => {
            state.language = language
            localStorage.setItem('language', language)
        },
        // token
		SET_TOKEN: (state, token) => {
			state.token = token
			localStorage.setItem('token', token)
		},
        // 用户信息
		SET_USERINFO: (state, userInfo) => {
			state.userInfo = userInfo
			localStorage.setItem('userInfo', JSON.stringify(userInfo))
		},

    },
    actions: {
        // 中英文
        setLanguage({
            commit
        }, language) {
            commit('SET_LANGUAGE', language)
        },
        // token
		setToken({
			commit
		}, token) {
			commit('SET_TOKEN', token)
		},
        // userInfo
		setUserInfo({
			commit
		}, userInfo) {
			commit('SET_USERINFO', userInfo)
		},


    }

}

export default app